/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div class="item-title">
      <div class="subject">
        <h3>举报管理</h3>
        <h5>商城设置举报类型及处理被举报商品</h5>
      </div>
      <ul class="tab-base nc-row">
        <router-link :to="{name:'expose', params:{state:1}}">
          <li>
            <a>
              <span>未处理</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'expose', params:{state:2}}">
          <li>
            <a>
              <span>已处理</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'expose_type'}" active-class="current">
          <li>
            <a>
              <span>类型设置</span>
            </a>
          </li>
        </router-link>
        <!-- <router-link :to="{name:'expose_subject'}">
          <li>
            <a>
              <span>主题设置</span>
            </a>
          </li>
        </router-link> -->
      </ul>
    </div>
    <div
      id="explanation"
      class="explanation"
      style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;"
    >
      <div class="bckopa-tips">
        <div class="title">
          <img src="@/static/images/handd.png" alt />
          <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        </div>
        <ul>
          <li>可在同一举报类型下添加多个举报主题</li>
        </ul>
      </div>
      <span title="收起提示" id="explanationZoom" style="display: block;"></span>
    </div>

    <div class="mDiv">
      <div class="ftitle">
        <h3>举报类型列表</h3>
        <h5>(共 {{totalCount}} 条记录)</h5>
      </div>
      <a @click="toAdd()">
        <div class="fbutton">
          <div class="add">
            <span>
              <i class="el-icon-circle-plus"></i> 新增数据
            </span>
          </div>
        </div>
      </a>
      <a href @click.prevent="refresh()" class="refresh-date">
        <div title="刷新数据" class="pReload">
          <i class="fa fa-refresh"></i>
        </div>
      </a>
    </div>

    <div class="tablebox">
      <el-table :data="tableData">
        <el-table-column label="举报类型" prop="expose_type_name" width="180" show-overflow-tooltip></el-table-column>
        <el-table-column label="举报类型描述" prop="expose_type_desc" width="180"></el-table-column>
        <el-table-column label="状态" prop="expose_type_state_detail" width="180"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button-group>
              <el-button
                size="small"
                @click="delFn(scope.row.expose_type_id)"
                icon="el-icon-delete"
              >删除</el-button>
            </el-button-group>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { getExpostTypeList, deleteExpostType } from "@/utils/api";
export default {
  data() {
    return {
      tableData: [],
      totalCount: 0
    };
  },
  created() {
    this.getType();
  },
  methods: {
    getType() {
      var that = this;
      getExpostTypeList().then(function(res) {
        that.tableData = res;
        that.totalCount = res.length;
      });
    },
    refresh() {
      this.getType();
      this.$message.success("刷新成功！");
    },
    toAdd() {
      this.$router.push({
        name: "add_expose_type"
      });
    },
    delFn(id) {
      var that = this;
      this.$confirm("是否删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          deleteExpostType(id).then(function(res) {
            if (res.status == 1) {
              that.$message.success("删除成功!");
              that.getType();
            } else {
              that.$message.error(res.msg);
            }
          });
        })
        .catch(() => {
          this.$message.info("已取消删除");
        });
    }
  }
};
</script>

<style scoped>
</style>
